package cn.airia.as3wplib.service.impl
{
	import cn.airia.as3wplib.cfg.Configuration;
	import cn.airia.as3wplib.rpc.BaseServiceDelegate;
	import cn.airia.as3wplib.rpc.DelegateFactory;
	import cn.airia.as3wplib.service.IMovableTypeService;
	
	public class MovableTypeServiceImpl implements IMovableTypeService
	{
		private var xmlrpc_url:String = Configuration.getInstance().xmlrpcUrl;
		private var movableTypeXmlrpc:BaseServiceDelegate;
		
		public function MovableTypeServiceImpl()
		{
			movableTypeXmlrpc = DelegateFactory.getDelegate(DelegateFactory.TYPE_XMLRPC,xmlrpc_url);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IMovableTypeService#getCategoryList()
		 */
		public function getCategoryList(blog_id:int, username:String, password:String, retFun:Function):void
		{
			var params:Array = new Array(blog_id,username,password);
			movableTypeXmlrpc.invoke("mt.getCategoryList",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IMovableTypeService#getRecentPostTitles()
		 */
		public function getRecentPostTitles(blog_id:int, username:String, password:String, num_posts:int, retFun:Function):void
		{
			var params:Array = new Array(blog_id,username,password,num_posts);
			movableTypeXmlrpc.invoke("mt.getRecentPostTitles",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IMovableTypeService#getRecentPostTitles()
		 */		
		public function getPostCategories(post_id:int, username:String, password:String, num_posts:int, retFun:Function):void
		{
			var params:Array = new Array(post_id,username,password,num_posts);
			movableTypeXmlrpc.invoke("mt.getPostCategories",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IMovableTypeService#setPostCategories()
		 */		
		public function setPostCategories(post_id:int, username:String, password:String, categories:Array, retFun:Function):void
		{
			var params:Array = new Array(post_id,username,password,categories);
			movableTypeXmlrpc.invoke("mt.setPostCategories",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IMovableTypeService#supportedMethods()
		 */		
		public function supportedMethods(retFun:Function):void
		{
			movableTypeXmlrpc.invoke("mt.supportedMethods",new Array(),retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IMovableTypeService#supportedTextFilters()
		 */		
		public function supportedTextFilters(retFun:Function):void
		{
			movableTypeXmlrpc.invoke("mt.supportedTextFilters",new Array(),retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IMovableTypeService#getTrackbackPings()
		 */		
		public function getTrackbackPings(post_id:int, retFun:Function):void
		{
			var params:Array = new Array(post_id);
			movableTypeXmlrpc.invoke("mt.getTrackbackPings",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IMovableTypeService#publishPost()
		 */		
		public function publishPost(post_id:int, username:String, password:String, retFun:Function):void
		{
			var params:Array = new Array(post_id,username,password);
			movableTypeXmlrpc.invoke("mt.publishPost",params,retFun);
		}
	}
}